#!/bin/bash

# 将当前目录设置为 scriptPATH
scriptPATH=$(cd $(dirname $0);pwd)

get_info(){
    date=`   /bin/bash $scriptPATH/cc_date.sh`    # 时间
    bat=`    /bin/bash $scriptPATH/cc_bat.sh`     # 电池电量
    vol=`    /bin/bash $scriptPATH/cc_vol.sh`     # 音量
    cpu=`    /bin/bash $scriptPATH/cc_cpu.sh`     # cpu 占用率
    mem=`    /bin/bash $scriptPATH/cc_mem.sh`     # 内存 占用
    network=`/bin/bash $scriptPATH/cc_network.sh` # 网络速率
    other=`  /bin/bash $scriptPATH/cc_other.sh`   # 其他显示 (docker clash\蓝牙)
}

while true
do
    [ "${MY_LOCK}" != "$0"  ] && exec env MY_LOCK="$0" flock -xn "$0" "$0" "$@"

    get_info
    #xsetroot -name "$other $network $vol $bat $date"
    xsetroot -name "$other $network $cpu $vol $bat $date"
    sleep 1s
done
